package cn.edu.lynu.chapter02;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class test333 {
    public static void main(String[] args) throws IOException {
        System.out.println("请输入您想查找的词查看是否存在：");
        BufferedReader br = new BufferedReader(new FileReader("D:\\百度分词词库.txt"));
        //声明数组集合，给定一个无规定的数组集合
        ArrayList<String> array = new ArrayList<String>();
        String line;
        while ((line = br.readLine()) != null) {
            //逐行读取，利用readline方法对line进行赋值，直到最后一个null
            array.add(line);
          //赋值给数组

        }
        br.close();//释放内存
        Scanner sc = new Scanner(System.in);
        String c = sc.nextLine();


        while (!c.equals("exit")) {
            boolean status = array.contains(c);//判断array中是否包含输入字符串

            if (status) {
                System.out.println("存在");

            } else {
                System.out.println("不存在");

            }

            int result1 = array.indexOf(c);//得到字符串所在的位置
            System.out.println(result1+1);
            c = sc.nextLine();

        }


    }
}




